<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>samplef</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function  </center>
    <div align="right">Last update : 13/01/2005</div>
    <p>
      <b>samplef</b> -   sample with replacement from a population
  and frequences of his values.</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>s = samplef(n,X,f,orient)</tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>n</b>
        </tt>: positive integer (size of sample)</li>
      <li>
        <tt>
          <b>X</b>
        </tt>: matrix. Samples will be extracted from this matrix</li>
      <li>
        <tt>
          <b>f</b>
        </tt>: positive integer matrix with same type than X. It indicates frequences
       of corresponding values of X.</li>
      <li>
        <tt>
          <b>orient</b>
        </tt>: Optional parameter. Admissible values are 1, 2, 'r' or 'c'</li>
      <li>
        <tt>
          <b>s</b>
        </tt>:  vector or matrix containing sample</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
   This function gives s, a  vector of lenght n.  It contains
   a  sample of  n  extractions, with  replacement, from  the
   vector  (or  matrix)  X,  each element  counted  with  the
   frequence given by the corresponding value in vector f.
</p>
    <p>
   s=samplef(n,X,f)   (or  s=samplef(n,X,f,'*'))   returns  a
   vector s whose values are a random sample of n values from
   X,   each  value   with  a   probability  to   be  sampled
   proportional  to the corresponding  value of  f, extracted
   with replacement, from X.  f must have same lenght than X.
</p>
    <p>
   s=samplef(n,X,f,'r')           (or,          equivalently,
   s=samplef(n,X,f,1))    returns    a    matrix   of    type
   size(X,'r')xn.  It contains a random sample of n rows from
   X, each row with  a probability to be sampled proportional
   to   the  corresponding   value  of   f,   extracted  with
   replacement, from the  rows of X. The lenght  of f must be
   equal to the number of rows of X.
</p>
    <p>
   s=samplef(n,X,f,'c')           (or,          equivalently,
   s=samplef(n,X,f,2))    returns    a    matrix   of    type
   nxsize(X,'c').  It  contains a random sample  of n columns
   from  X, each  column  with a  probability  to be  sampled
   proportional  to the corresponding  value of  f, extracted
   with replacement, from the columns  of X.  The lenght of f
   must be equal to the number of columns of X.
</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>
   a=[3 7 9;22 4 2]
   f1=[10 1 1 1 1 1]
   f2=[1 ; 15]
   f3=[10 1 1]
   s=samplef(15,a,f1)
   s=samplef(15,a,f2,'r')
   s=samplef(15,a,f3,'c')

  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="sample.htm">
        <tt>
          <b>sample</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="samwr.htm">
        <tt>
          <b>samwr</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
    <h3>
      <font color="blue">Author</font>
    </h3>
    <p>
   Carlos Klimann
  </p>
  </body>
</html>
